/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.edu.flf.audioteca.dao.entidades.impl;

import br.edu.flf.audioteca.dao.entidades.IAlbumDAO;
import br.edu.flf.audioteca.dao.exceptions.JPAException;
import br.edu.flf.audioteca.dao.impl.EntidadeEscritaDAO;
import br.edu.flf.audioteca.entidades.Album;
import javax.persistence.EntityManager;

/**
 *
 * @author Nathan Azevedo
 */
public class AlbumDAO extends EntidadeEscritaDAO implements IAlbumDAO {

    private static IAlbumDAO albumDAO;

    public static IAlbumDAO getInstace() {
        if (albumDAO == null) {
            albumDAO = new AlbumDAO();
        }
        return albumDAO;
    }

    public void persistirArtista(Album album) throws JPAException {
        EntityManager entityManager = getEntityManager();
        try {
            entityManager.getTransaction().begin();
            entityManager.merge(album);
            entityManager.getTransaction().commit();
        } catch (Exception e) {
            e.printStackTrace();
            throw new JPAException(e);
        } finally {
            entityManager.close();

        }

    }
}
